#!/bin/bash
#linuxsamu
kafka_home={{kafka_base}}
START_USER={{kafka_run_user}}

startfunc()
{
    su ${START_USER}<<!
    ${kafka_home}/bin/zookeeper-server-start.sh -daemon ${kafka_home}/config/zookeeper.properties
    sleep 10
    ${kafka_home}/bin/kafka-server-start.sh -daemon ${kafka_home}/config/server.properties
!
}
stopfunc()
{
    su ${START_USER}<<!
    ${kafka_home}/bin/kafka-server-stop.sh ${kafka_home}/config/server.properties
    sleep 5
    ${kafka_home}/bin/zookeeper-server-stop.sh ${kafka_home}/config/zookeeper.properties
!
}
case $1 in
    start)
        startfunc
        ;;
    stop)
        stopfunc
        ;;
    restart)
        stopfunc
        startfunc
        ;;
    *)
        echo "用法:$0 start|stop|restart"  
        ;;
esac
